/**
 *
 *
 * @author tangzehua
 * @since 2016-11-13 22:56
 */
import React, { Component } from 'react';
import {
    StyleSheet,
    Image,
    Text,
    View,

} from 'react-native';
import TabNavigator from 'react-native-tab-navigator';
import  Index from './../index';
import  Rednormal from './rednormal'
const HOME = 'home';
export default class Footer extends  Component{
    constructor(props) {
        super(props);
        this.state = {selectedTab: HOME}
    }

    _renderTabItem(img, selectedImg, tag, childView) {
        return (
            <TabNavigator.Item
                selected={this.state.selectedTab === tag}
                renderIcon={() => <Image style={styles.tabIcon} source={img}/>}
                renderSelectedIcon={() => <Image style={styles.tabIcon} source={selectedImg}/>}
                onPress={() => this.setState({ selectedTab: tag })}>
                {childView}
            </TabNavigator.Item>
        );
    }
    render(){
        return(
            <TabNavigator hidesTabTouch={true} tabBarStyle={styles.tab}>
                {this._renderTabItem(require('./../img/sy_01.png'), require('./../img/sy_02.png'), HOME,<Index navigator={this.props.navigator}/>)}
                {this._renderTabItem(require('./../img/hd_01.png'), require('./../img/hd_02.png'), 'hd',<Rednormal navigator={this.props.navigator}/>)}
                {this._renderTabItem(require('./../img/tz_01.png'), require('./../img/tz_02.png'), 'tz',<Index navigator={this.props.navigator}/>)}
                {this._renderTabItem(require('./../img/wd_01.png'), require('./../img/wd_02.png'), 'wd',<Index navigator={this.props.navigator}/>)}
            </TabNavigator>
        );
    }
}
const styles = {
    tabIcon: {
        width: 25,
        height: 25,
        resizeMode: 'stretch',
        marginTop: 12.5
    }
};